module MC {
	export module msg {
		export function show(txt: string) {
			var wrap = document.createElement('div');
			$(wrap).css({
				'position': 'fixed',
				'top': '50%',
				'left': '50%',
				'transform': 'translate(-50%,-50%)',
				'-webkit-transform': 'translate(-50%,-50%)',
				'max-width': '50%',
				'padding': '.2rem .4rem',
				'color': 'white',
				'z-index': '20',
				'background': 'rgba(0,0,0,0.7)',
				'border-radius': '.08rem',
				'display': 'none',
				'font-size': '14px'
			});
			$(wrap).html(txt);
			$('body').append($(wrap));
			$(wrap).fadeIn();
			setTimeout(function () {
				$(wrap).fadeOut(function () {
					$(wrap).remove();
				});
			}, 1500);
		}
		export function alert(text: string,fun:Function=null){
			let html =$( ` 
			<div class="msgbody"> 
			<div class="msgBox">
				<div class="boxcon">`+ text + `</div>
				<div class="butarray clearfix"> 
					<a class="button closebtn buttonputong">关闭</a>
				</div>
			</div></div>`); 
			html.find('.closebtn').click(()=>{
				html.remove();
                fun&&fun();
			});
			$('body').append(html);
		}

		/*** 带有确认按钮的消息框 */
		export function confirm(text: string, fun: Function) {
			let html =$( ` 
			<div class="msgbody"> 
			<div class="msgBox">
				<div class="boxcon">`+ text + `</div>
				<div class="butarray clearfix">
					<a class="button savebtn">确定</a>
					<a class="button closebtn buttonputong">关闭</a>
				</div>
			</div></div>`);
			html.find('.savebtn').click(()=>{
				fun();
				html.remove();
			});
			html.find('.closebtn').click(()=>{
				html.remove();
			});
			$('body').append(html);
		}



	}
}